﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WindowsGame1
{
    class StateSequence : State
    {
        public List<State> states = new List<State>();
        public bool loop = false;
        public int index = 0;

        public StateSequence(Alien a)
            : base(a)
        {

        }

        public StateSequence(Alien alien, State[] ss)
            : base(alien)
        {
            foreach (State s in ss)
            {
                states.Add(s);
            }
        }


        public override bool Update(Timer t)
        {
            if (index < states.Count)
            {
                bool r = states[index].Update(t);
                if (r == false)
                    index++;
            }

            if (loop && index == states.Count)
                index = 0;

            return index < states.Count;
        }
    }
}
